<div class="head">Sign Up</div>

<p /><div class="subhead">You're almost there!</div>

<p />Congratulations on your decision to sign up for The Pin Project! In a few moments, you will become a part of our growing community of artists, musicians, photographers, programmers, gaming enthusiasts, and more.

<p />Please fill out the following form:
<br>Required fields are marked with an asterisk (<span class="redtext">*</span>)
	
<div class="redtext" id="response"></div>

<table>
	<tr>
		<td><span class="redtext">*</span> Username:</td>
		<td><input type="text" name="usern" id="usern" size="20"/></td>
	</tr>
	
	<tr>
		<td><span class="redtext">*</span> Password:</td>
		<td><input type="password" id="password1" size"20"/></td>
	</tr>
	
	<tr>
		<td><span class="redtext">*</span> Re-Enter Password:</td>
		<td><input type="password" id="password2" size="20"/></td>
	</tr>

	<tr>
		<td><div class="horizontal_separation"></div></td>
	</tr>
	
	<tr>
		<td><img src="img/arrow_green.gif"><a href="javascript:ShowMessage('privacy', 0); ", class="privacy">Privacy Policy</a></td>
	</tr>
	
	<tr>
		<td><div class="horizontal_separation"></div></td>
	</tr>
	
	<tr>
		<td>Email Address:</td>
		<td><input id="email" type="text" /></td>
	</tr>
	
	<tr>
		<td>First Name:</td>
		<td><input id="firstn" type="text" /></td>
	</tr>
	
	<tr>
		<td>Last Name:</td>
		<td><input id="lastn" type="text" /></td>
	</tr>
	
	<tr>
		<td></td>
		<td><input type="button" name="submit" value="Join!" onclick="check(); " /></td>
	</tr>
</table>
	
	

			
<div class="context_message" id="context_message" style="display: none;">
	<div id="message_text"></div>
	<div style="text-align: right" id="message_choices"></div>
</div>

<div id="hiddenform">

	<form method="post" action="/frame.php?page=createuser.php" name="hiddenform">
		<input type="hidden" value="" name="husern" id="husern" />
		<input type="hidden" value="" name="hpassword" id="hpassword" />
		<input type="hidden" value="" name="hemail" id="hemail" />
		<input type="hidden" value="" name="hfirstname" id="hfirstname" />
		<input type="hidden" value="" name="hlastname" id="hlastname" />
	</form>

</div>

<script type="text/javascript">
	function ShowMessage(message, choiceType)
	{
		destObj = document.getElementById("message_text")
		switch (message)
		{
			case 'privacy':
				destObj.innerHTML = "The Pin Project will not use any of your personal information including, but not limited to, e-mail addresses, name(s), etc. for any purposes outside the normal functions of the site.  We will not disclose this information to any third parties or fourth parties, and will use this information only in accordance with the user's preference.";
				break;
		}
		
		destObj = document.getElementById("message_choices")
		switch (choiceType)
		{
			case 0:
				destObj.innerHTML = '<a href="javascript:MessageResponse(1);">Ok</a>';
				break;
			case 1:
				destObj.innerHTML = '<a href="javascript:MessageResponse(1);">Yes</a> | <a href="#" onclick="MessageResponse(0);">No</a>';
				break;
		}
		
		destObj = document.getElementById("context_message");
		destObj.style.display = "block";
	}
	
	function MessageResponse(responseID)
	{
		destObj = document.getElementById("context_message");
		destObj.style.display = "none";
	}
	
	
	
	function check()
	{
		
		var username = document.getElementById('usern').value;
		var password1 = document.getElementById('password1').value;
		var password2 = document.getElementById('password2').value;
		var email = document.getElementById('email').value;
		var firstname = document.getElementById('firstn').value;
		var lastname = document.getElementById('lastn').value;
		
		// create the XMLHttpRequest object
		var request;
		try { request = new XMLHttpRequest(); }
		catch(e)
		{
		   try { request = new ActiveXObject("Msxml2.XMLHTTP"); }
		   catch(e)
		   {
		        try { request = new ActiveXObject("Microsoft.XMLHTTP"); }
		        catch(e)
		        {
		             alert("Your browser will not support this webpage.");
		             return false;
		        }
		   }
		}
		
		request.open("POST", 'checkAddUser.php', true);
		
		request.onreadystatechange = function()
		{
		   if(request.readyState == 4)
		   {
		       	var responseArray = request.responseText.split(",");
		
		        var attemptValidity = responseArray[0];
		        var attemptText = responseArray[1];
		        
		        if (attemptValidity==1)
		        {
			        
			        document.hiddenform.husern.value = username;
			        document.hiddenform.hpassword.value = password1;
			        document.hiddenform.hemail.value = email;
			        document.hiddenform.hfirstname.value = firstname;
			        document.hiddenform.hlastname.value = lastname;
			        
			        document.hiddenform.submit();
		        }

				document.getElementById('response').innerHTML = "<p>" + attemptText+ "<p>";		        
		   }
		}

		request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		request.send('username=' + username + '&password1=' + password1 + '&password2=' + password2 +
			'&email=' + email + '&firstname=' + firstname + '&lastname=' + lastname); 
			
		
	}

</script>